home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-ALPH.{_4 / PAGE.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  3KB  |  126 lines

  1. #ifndef _ALPHA_PAGE_H
  2. #define _ALPHA_PAGE_H
  3.  
  4. /* PAGE_SHIFT determines the page size */
  5. #define PAGE_SHIFT    13
  6. #define PAGE_SIZE    (1UL << PAGE_SHIFT)
  7. #define PAGE_MASK    (~(PAGE_SIZE-1))
  8.  
  9. #ifdef __KERNEL__
  10.  
  11. #ifndef __ASSEMBLY__
  12.  
  13. #define STRICT_MM_TYPECHECKS
  14.  
  15. /*
  16.  * A _lot_ of the kernel time is spent clearing pages, so
  17.  * do this as fast as we possibly can. Also, doing this
  18.  * as a separate inline function (rather than memset())
  19.  * results in clearer kernel profiles as we see _who_ is
  20.  * doing page clearing or copying.
  21.  */
  22. static inline void clear_page(unsigned long page)
  23. {
  24.     unsigned long count = PAGE_SIZE/64;
  25.     unsigned long *ptr = (unsigned long *)page;
  26.  
  27.     do {
  28.         ptr[0] = 0;
  29.         ptr[1] = 0;
  30.         ptr[2] = 0;
  31.         ptr[3] = 0;
  32.         count--;
  33.         ptr[4] = 0;
  34.         ptr[5] = 0;
  35.         ptr[6] = 0;
  36.         ptr[7] = 0;
  37.         ptr += 8;
  38.     } while (count);
  39. }
  40.  
  41. static inline void copy_page(unsigned long _to, unsigned long _from)
  42. {
  43.     unsigned long count = PAGE_SIZE/64;
  44.     unsigned long *to = (unsigned long *)_to;
  45.     unsigned long *from = (unsigned long *)_from;
  46.  
  47.     do {
  48.         unsigned long a,b,c,d,e,f,g,h;
  49.         a = from[0];
  50.         b = from[1];
  51.         c = from[2];
  52.         d = from[3];
  53.         e = from[4];
  54.         f = from[5];
  55.         g = from[6];
  56.         h = from[7];
  57.         count--;
  58.         from += 8;
  59.         to[0] = a;
  60.         to[1] = b;
  61.         to[2] = c;
  62.         to[3] = d;
  63.         to[4] = e;
  64.         to[5] = f;
  65.         to[6] = g;
  66.         to[7] = h;
  67.         to += 8;
  68.     } while (count);
  69. }
  70.  
  71. #ifdef STRICT_MM_TYPECHECKS
  72. /*
  73.  * These are used to make use of C type-checking..
  74.  */
  75. typedef struct { unsigned long pte; } pte_t;
  76. typedef struct { unsigned long pmd; } pmd_t;
  77. typedef struct { unsigned long pgd; } pgd_t;
  78. typedef struct { unsigned long pgprot; } pgprot_t;
  79.  
  80. #define pte_val(x)    ((x).pte)
  81. #define pmd_val(x)    ((x).pmd)
  82. #define pgd_val(x)    ((x).pgd)
  83. #define pgprot_val(x)    ((x).pgprot)
  84.  
  85. #define __pte(x)    ((pte_t) { (x) } )
  86. #define __pgd(x)    ((pgd_t) { (x) } )
  87. #define __pgprot(x)    ((pgprot_t) { (x) } )
  88.  
  89. #else
  90. /*
  91.  * .. while these make it easier on the compiler
  92.  */
  93. typedef unsigned long pte_t;
  94. typedef unsigned long pmd_t;
  95. typedef unsigned long pgd_t;
  96. typedef unsigned long pgprot_t;
  97.  
  98. #define pte_val(x)    (x)
  99. #define pmd_val(x)    (x)
  100. #define pgd_val(x)    (x)
  101. #define pgprot_val(x)    (x)
  102.  
  103. #define __pte(x)    (x)
  104. #define __pgd(x)    (x)
  105. #define __pgprot(x)    (x)
  106.  
  107. #endif /* STRICT_MM_TYPECHECKS */
  108. #endif /* !ASSEMBLY */
  109.  
  110. /* to align the pointer to the (next) page boundary */
  111. #define PAGE_ALIGN(addr)    (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  112.  
  113. #ifdef USE_48_BIT_KSEG
  114. #define PAGE_OFFSET        0xffff800000000000
  115. #else
  116. #define PAGE_OFFSET        0xfffffc0000000000
  117. #endif
  118.  
  119. #define __pa(x)            ((unsigned long) (x) - PAGE_OFFSET)
  120. #define __va(x)            ((void *)((unsigned long) (x) + PAGE_OFFSET))
  121. #define MAP_NR(addr)        (__pa(addr) >> PAGE_SHIFT)
  122.  
  123. #endif /* __KERNEL__ */
  124.  
  125. #endif /* _ALPHA_PAGE_H */
  126.